perm filename MACROS.SAI[AL,HE]3 blob sn#358171 filedate 1978-05-30 generic text, type T, neo UTF8
COMMENT USEFUL MACROS FOR SAIL PROGRAMS;
REQUIRE "[][]" DELIMITERS;
DEFINE SYMNO=0;
DEFINE INITIALIZE(X)=
	[ REDEFINE SYMNO=SYMNO+1;
	REDEFINE INIT00="INIT"&CVS(SYMNO);
	SIMPLE PROCEDURE INIT00; X;
	REQUIRE INIT00 INITIALIZATION ];
DEFINE GENSYM =
	[ REDEFINE SYMNO=SYMNO+1;
	"___"&CVS(SYMNO) ];
DEFINE SIMPROC=[SIMPLE PROCEDURE],
	RECPROC=[RECURSIVE PROCEDURE ];

DEFINE ON_BLOCK_EXIT_DO(BODY,ATTR)=
        [ REDEFINE SYMNO=SYMNO+1;
	REDEFINE CLN00="CLN"&CVS(SYMNO);
	ATTR PROCEDURE CLN00;
		BODY;
	CLEANUP CLN00 ];

DEFINE DEFQ(LNGID,SHTID) = [
	REDEFINE LNGID "<>" = <SHTID>;
	SHTID ];


COMMENT DEFQ is intended to be used in declarations where you
	want a longer identifier than that allowed by the loader
	e.g.

	EXTERNAL PROCEDURE DEFQ(A_LONG_NAME_1,ALN1__)

	;

DEFINE NO_COMPILE = [IFCR FALSE THENC];

DEFINE BUG(S)=[USERERR(1,1,S)];

DEFINE BITDEF(BITID,V,XX)"[]" = [
	DEFINE BITID "<>" = <V>;
	ASSIGNC XX "[]" = CVPS(BITID)&[_ON];
	DEFINE XX (I) "[]" = [((I) LAND (]&CVPS(V)&[))]
];

DEFINE ITERATE "[]" = [WHILE TRUE DO];

DEFINE CALLBAIL "[]" = [
	IFCR BAILING THENC
	BEGIN EXTERNAL PROCEDURE BAIL;BAIL;END
	ENDC];


DEFINE WHILE_GENERATE "[]" = [ FOREACH SUCH THAT ];

IFCR ¬DECLARATION(BAILING) THENC DEFINE BAILING "<>" = <FALSE>; ENDC

    REQUIRE "<><>" DELIMITERS;

    DEFINE NewArray(type,name,bounds) =<
	BEGIN
	type ARRAY proxy bounds;
	MEMORY[LOCATION(name)] ← MEMORY[LOCATION(proxy)];
	MEMORY[LOCATION(proxy)] ← 0;
	END>;

    REQUIRE UNSTACK_DELIMITERS;